package com.wish.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wish.entity.TCwDealPerDay;
import com.wish.entity.TCwDealPerDayVo;
import com.wish.service.ITCwDealPerDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 五组
 * @since 2021-04-09
 */
@RestController
@RequestMapping("/wish/t-cw-deal-per-day")
public class TCwDealPerDayController {

    @Autowired
    private ITCwDealPerDayService itCwDealPerDayService;

    @RequestMapping("getList")
    public Page<TCwDealPerDay> getList(TCwDealPerDayVo tCwDealPerDayVo){
        QueryWrapper<TCwDealPerDay> wrapper = new QueryWrapper<>();
        if (tCwDealPerDayVo.getStartTime() != null && tCwDealPerDayVo.getStartTime()!=""){
            wrapper.gt("deal_date",tCwDealPerDayVo.getStartTime());
        }
        if (tCwDealPerDayVo.getEndTime() != null && tCwDealPerDayVo.getEndTime() !=""){
            wrapper.lt("deal_date",tCwDealPerDayVo.getEndTime());
        }
        if (tCwDealPerDayVo.getMx() != 0){
            wrapper.eq("operation_type",tCwDealPerDayVo.getMx());
        }
        Page<TCwDealPerDay> page = new Page<>();
        page.setCurrent(tCwDealPerDayVo.getPageNum());
        page.setSize(tCwDealPerDayVo.getPageSize());
        Page pageInfo = itCwDealPerDayService.getList(wrapper,page);
        return pageInfo;
    }

    @RequestMapping("getLists")
    public Page<TCwDealPerDay> getLists(TCwDealPerDayVo tCwDealPerDayVo){
        QueryWrapper<TCwDealPerDay> wrapper = new QueryWrapper<>();
        tCwDealPerDayVo.setMx(2);
        if (tCwDealPerDayVo.getStartTime() != null && tCwDealPerDayVo.getStartTime()!=""){
            wrapper.gt("deal_date",tCwDealPerDayVo.getStartTime());
        }
        if (tCwDealPerDayVo.getEndTime() != null && tCwDealPerDayVo.getEndTime() !=""){
            wrapper.lt("deal_date",tCwDealPerDayVo.getEndTime());
        }
        if (tCwDealPerDayVo.getMx() != 0){
            wrapper.eq("operation_type",tCwDealPerDayVo.getMx());
        }
        Page<TCwDealPerDay> page = new Page<>();
        page.setCurrent(tCwDealPerDayVo.getPageNum());
        page.setSize(tCwDealPerDayVo.getPageSize());
        Page pageInfo = itCwDealPerDayService.getLists(wrapper,page);
        return pageInfo;
    }

}
